const axios = require('axios')
const _baseUrl = '/gateway/business/api'

// 获取公开项目事例
export function getPublicProjectExample () {
  const url = _baseUrl + '/project/getPublicProjectExample'
  return axios.get(url).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 获取任务不同状态统计结果
export function getTaskStatus () {
  const url = _baseUrl + '/project/getTaskStatistics'
  return axios.get(url).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 获取项目列表
export function getProjectList (query) {
  const url = _baseUrl + '/project' + query
  return axios.get(url).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 创建项目
export function createProject (data, param) {
  const url = _baseUrl + '/project' + param
  return axios.post(url, data).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 使用该数据集的项目列表
export function getProjectListByDatasetId (query) {
  const url = _baseUrl + '/project/getProjectListByDatasetId' + query
  return axios.get(url).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 我的数据集的项目列表
export function getUserProjectListByDatasetId (query) {
  const url = _baseUrl + '/project/getUserProjectListByDatasetId' + query
  return axios.get(url).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 获取任务视图列表
export function getTaskViewList (query) {
  const url = _baseUrl + '/project/getTaskViewList' + query
  return axios.get(url).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 查询用户项目明细
export function getProjectDetailByProjectId (query) {
  const url = _baseUrl + '/project/getUserProjectDetail' + query
  return axios.get(url).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 获取用户任务详情
export function getUserTaskDetail (query) {
  const url = _baseUrl + '/project/getUserTaskDetail' + query
  return axios.get(url).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 查询项目明细
export function getProjectDetail (query) {
  const url = _baseUrl + '/projectDetail' + query
  return axios.get(url).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 添加标签
export function saveJobTag (data) {
  const url = _baseUrl + '/project/saveJobTag'
  return axios.post(url, data).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 修改标签
export function updateJobTag (data) {
  const url = _baseUrl + '/project/updateJobTag'
  return axios.post(url, data).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 查询项目明细
export function getIdFindDataset (query) {
  const url = _baseUrl + '/project/getPrivateInfo' + query
  return axios.get(url).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 查询标签列表
export function getjobTagListByUserId (data) {
  const url = _baseUrl + '/project/getjobTagListByUserId' + data
  return axios.get(url).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 标签种类
export function getjobTagListByProId (query) {
  const url = _baseUrl + '/project/getjobTagListByProId' + query
  return axios.get(url).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 任务操作
export function taskOperation (query) {
  const url = _baseUrl + '/jobOperation' + query
  return axios.post(url).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 新建任务
export function createTask (data) {
  const url = _baseUrl + '/createJob'
  return axios.post(url, data).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 公开项目
export function openProject (data) {
  const url = _baseUrl + '/project/openProject'
  return axios.post(url, data).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 搜索公开项目
export function searchPublicProjectList (query) {
  const url = _baseUrl + '/project/searchPublicProjectList' + query
  return axios.get(url).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 查询项目笔记
export function getProjectNotes (query) {
  const url = _baseUrl + '/project/getProjectNotes' + query
  return axios.get(url).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 编辑项目笔记
export function editProjectNotes (data) {
  const url = _baseUrl + '/project/editProjectNotes'
  return axios.post(url, data).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 复制项目
export function copyProject (query) {
  const url = _baseUrl + '/project/copyProject' + query
  // const url = '/weiwei' + '/project/copyProject' + query
  return axios.post(url).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 创建任务看板
export function createTensorBoard (data) {
  const url = _baseUrl + '/tensor/createContainer'
  return axios.post(url, data).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 编辑项目
export function editProject (data) {
  const url = _baseUrl + '/project/editProject'
  return axios.post(url, data).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 着陆页查询公开项目信息
export function getOpenProjectInfo (query) {
  const url = _baseUrl + '/openProjectInfo' + query
  return axios.get(url).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 着陆页类目及分类信息
export function getOpenProjectCategory () {
  const url = _baseUrl + '/category/getCategoryCount'
  return axios.post(url).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 新建时仅保存项目、编辑项目
export function projectEdit (query, data) {
  const url = _baseUrl + '/project' + query
  return axios.put(url, data).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 新建时仅保存项目、编辑项目
export function projectEdit2 (query, data) {
  const url = _baseUrl + '/saveJob' + query
  return axios.put(url, data).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 调试任务获取JupyterUrl
export function getJobJupyterUrl (query) {
  const url = _baseUrl + '/jobJupyterUrl' + query
  return axios.get(url).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 项目名是否可用
export function isUsable4Name (query, header) {
  const url = _baseUrl + '/project/isUsable4Name' + query
  return axios.get(url, header).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 添加或编辑任务备注
export function jobRemarkEdit (data) {
  const url = _baseUrl + '/jobRemarkEdit'
  return axios.post(url, data).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 任务详情页-获取output目录下文件列表
export function getJobOutPutFileList (query, header) {
  const url = _baseUrl + '/file/getJobOutPutFileList' + query
  return axios.get(url).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 获取最近新建的jupyter任务配置
export function getLastJupyterJobConfig (query, header) {
  const url = _baseUrl + '/project/getLastJupyterJobConfig'
  return axios.get(url).then((res) => {
    return Promise.resolve(res.data)
  })
}
